package org.example.platform.design.singleton;

/**
 * 单例模式测试
 */
public class SingletonTest {
    public static void main(String[] args) {
        // 使用new方法提示需要构造方法去除私有化
//        Singletion singletion = new Singletion();
        Singletion singletion = Singletion.getInstance();
        Singletion singletion2 = Singletion.getInstance();
        if(singletion2 ==singletion){
            System.out.println("singletion2+singletion两个对象是相同的实例");
        }


        SingletionTwo singletionTwo = new SingletionTwo();
        SingletionTwo singletionTwo2 = SingletionTwo.getInstance();
        SingletionTwo singletionTwo3 = SingletionTwo.getInstance();
        if(singletionTwo ==singletionTwo2){
            System.out.println("singletionTwo2+singletionTwo两个对象是相同的实例");
        }
        if(singletionTwo3 ==singletionTwo2){
            System.out.println("singletionTwo2+singletionTwo3两个对象是相同的实例");
        }
    }
}
